<template>
	<view class="content">
		<view class="row1">
			<image src="../../../static/icon/filecoin-logo@2x.png" mode=""></image>
			<text>FIL</text>
		</view>
		<view class="title">
			提币地址
		</view>
		<view class="inputbox">
			<input type="text" v-model="address" placeholder="请输入钱包地址"/>
		</view>
		<view class="title">
			提币数量
		</view>
		<view class="inputbox">
			<input type="text" v-model="amount" placeholder="最少可提 2 FIL"/>
			<!-- <text>全部</text> -->
		</view>
		<view class="title">
			资金密码
		</view>
		<view class="inputbox">
			<input type="password"  v-model="trade_password" placeholder="请输入资金密码(6位数字)"/>
		</view>
		<!-- <view class="title">
			请输入短信验证码
		</view>
		<view class="inputbox">
			<input type="text" v-model="address" placeholder="请输入短信验证码"/>
			<view v-show="!yan" @click="sendsms"  style="color: #0072FF;">获取验证码</view>
			<view v-show="yan" >{{second}}s</view>
		</view> -->
		<view class="mybtn" @click="tijiao">
			提交
		</view>
		<view class="tishibox">
			<rich-text :nodes="content" class="tishi2"></rich-text>
			<!-- <view class="tishi1">
				温馨提示：
			</view>
			<view class="tishi2">
				1、您的提币操作一旦完成，对应的资产所有权将由您变更为
				目标地址对应的账户所有人享有。<br>
				2、最小提币数量：0.001FIL<br>
				3、提币手续费：0.05FIL<br>
				4、修改绑定邮箱、绑定手机、登录密码、资金密码24小时之
				内不可提现，请务必确认电脑及浏览器安全，防止信息被篡改
				或泄露。
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				yan:false,
				second:60,
				address:'',
				amount:'',
				trade_password:'',
				content:'',
			}
		},
		onLoad() {
			this.getinfo()
		},
		onHide() {
			this.address=''
			this.amount=''
			this.trade_password=''
			this.content=''
		},
		methods: {
			getinfo(){
				var token =uni.getStorageSync('token')
				if(token==''||token==null){
					uni.reLaunch({
					    url:'../../login/login'
					})
				}else{
					this.http({
					 	url:'/api/Ext/tbNotes',
					 	method:'POST',
						header:{
							'token':token
						},
					 	success:(res)=>{
							console.log(res)
							this.content = res.data.content
						},
					 	error:()=>{
					 		uni.showToast({
					 			title:"请求异常"	
					 		})
					 	},	
					 })
				} 
			},
			sendsms(){
				var token =uni.getStorageSync('token')
				if(token==''||token==null){
					uni.reLaunch({
					    url:'../login/login'
					})
				}else{
					if(this.yan ){
						return false
					}
					this.yan = true
					
					this.http({
						url:'/api/Login/sendsms',
						method:'POST',
						header:{
							'token':token
						},
						success:res=>{
							console.log(res)
							uni.showToast({
								title:res.msg,
								icon:'none'
							})
							let interval = setInterval(() => {
							        --this.second
							    }, 1000)
							setTimeout(() =>{
								 clearInterval(interval)
								 this.second =60
								 this.yan = false
							}, 60000);
						},
						fail:err =>{
						  	uni.showToast({
						  		title:res.data.msg,
						  		icon:'none'
						  	})
						},	
					})
				}
				
			},
			tijiao(){
				if(this.address !=''&&this.amount !=''){
					var regex =/^\d{6}$/;
					
					if(!regex.test(this.trade_password*1)){
						uni.showToast({
							title:'密码输入错误，请重新输入',
							icon:'none'
						})
						console.log('11111111111')
					}else{
						console.log('mimazhegnque')
						var token =uni.getStorageSync('token')
						if(token==''||token==null){
							uni.reLaunch({
							    url:'../../login/login'
							})
						}else{
							this.http({
							 	url:'/api/User/getOut',
							 	method:'POST',
								header:{
									'token':token
								},
								data:{
									address:this.address,
									amount:this.amount,
									trade_password:this.trade_password
								},
							 	success:(res)=>{
									console.log(res)
									if(res.code ==1){
										uni.showToast({
											title:res.msg,
											icon:'none'
										})
										setTimeout(()=>{
											uni.navigateTo({
												url:'../filjilu?currentIndex=1'
											})
										},500)
										this.address=''
										this.amount = ''
										this.trade_password = ''
									}
								},
							 	error:()=>{
							 		uni.showToast({
							 			title:"请求异常"	
							 		})
							 	},	
							 })
						} 
					}
				}else{
					uni.showToast({
						title:'请输入内容',
						icon:'none'
					})
				}
				
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC;
		font-weight: 500;
		color:#2b2b2b;
		padding-bottom: 50rpx;
		.mybtn{
			width: 690rpx;
			height: 88rpx;
			margin: 30rpx auto;
			background-color: #0072FF;
			border-radius: 20rpx;
			text-align: center;
			line-height: 88rpx;
			font-size: 36rpx;
			font-weight: 700;
			color: #FFFFFF;
		}
		.row1{
			width: 750rpx;
			height: 91rpx;
			border-top: 1rpx solid #cccccc;
			border-bottom: 1rpx solid #cccccc;
			margin: 20rpx auto 25rpx auto;
			display: flex;
			align-items: center;
			font-size: 30rpx;
			font-weight: bold;
			image{
				margin:0 19rpx 0 60rpx;
				width: 45rpx;
				height: 44rpx;
			}
		}
		.title{
			width: 750rpx;
			font-size: 30rpx;
			font-weight: bold;
			color: #2B2B2B;
			margin-left: 61rpx;
		}
		.inputbox{
			width: 627rpx;
			height: 98rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 2px 0px rgba(43, 43, 43, 0.18);
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			padding: 0 32rpx 0 31rpx;
			margin: 25rpx auto;
			input{
				flex: 1;
			}
		}
		.tishibox{
			width: 690rpx;
			.tishi1{
				font-size: 28rpx;
				color: #CCCCCC;
			}
			.tishi2{
				margin: 20rpx auto;
				font-size: 26rpx;
				color: #CCCCCC;
			}
		}
	}

	
</style>
